-- GainItemWaysM
-- Create by huanghr
-- 物品获取方式

module("GainItemWaysM", package.seeall);

-- 获取Item物品的信息
local WaysInfo = {};

-- 载入配置表
local _init = false;
local loadCsv = function()
    if _init then return end
    _init = true;

    -- 转换下GainItemWays信息表
    local gain_item_ways_CSV = get_gain_item_ways_CSV();
    for i = 1, #gain_item_ways_CSV do
        local itemId = gain_item_ways_CSV[i].id;

        WaysInfo[itemId] = gain_item_ways_CSV[i];
    end
    gain_item_ways_CSV = {};
end

-- 模块初始化
function init()
    loadCsv();
end

-- 检索信息
function query(id, path)
    local m = WaysInfo[id];
    if not m or path == "" or not path then
        return m;
    else
        return m[path];
    end
end